Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For my own reference, I added type hints to this library, and figured that it might be nice to upstream them to you.
Also, while doing this, I also found one place with a minor code error (trying to call
.hex()on a string instead of bytes) and a few places that did not double check that values were not None before proceeding, so I fixed those up. I took care to not otherwise change the actual code, or even the formatting.Adding type hints makes it easier to understand what the expected inputs and outputs of the code is, and has the added benefit of allowing the use of
mypycorcythonto generate a C based library from the Python code. In testing, I found that uses either one of them leads to a decent performance improvement (the test script went from taking about 90 seconds to taking about 60 seconds).One downside is that the use of the
types-docoptmodule means I had to restrict the minimum Python version to 3.8.